package com.atguigu.tingshu.comment.api;


import com.atguigu.tingshu.comment.service.CommentService;
import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.vo.comment.CommentVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/comment")
@Slf4j
public class CommentApiController {

	@Autowired
	private CommentService commentService;

	/**
	 * 保存新增评论
	 * @return
	 */
	@GuiguLogin
	@PostMapping("/save")
	public Result saveComment(@RequestBody CommentVo commentVo){
		commentService.saveComment(commentVo);
		return Result.ok();
	}

	/**
	 * 分页查询评论
	 * @return
	 */
	@GetMapping("/findCommentPage/{albumId}/{trackId}/{page}/{size}")
	public Result findCommentPage(@PathVariable("albumId") Long albumId,
								  @PathVariable("trackId") Long trackId,
								  @PathVariable("page") Integer page,
								  @PathVariable("size") Integer size){
		return Result.ok(commentService.findCommentPage(albumId,trackId,page,size));
	}


}

